#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'jack@csdn.com'


class Person(object):

    def __init__(self, name, age):
        self._name = name
        self._age = age

    @staticmethod
    def is_valid(name, age):
        if not isinstance(name, str):
            raise ValueError("name must be strig")
        if not isinstance(age, int):
            raise ValueError("age must be integer")

    @classmethod
    def now(cls):
        return cls(__author__, len(__author__))

    @property
    def age(self):
        return self._age

    @age.setter
    def age(self, value):
        if not isinstance(value, int):
            raise ValueError("age must be int structure")
        if value < 0 or value > 100:
            raise ValueError('age must between 0 ~ 100!')
        self._age = value

    @property
    def name(self):
        return self._name


if __name__ == '__main__':
    c = Person(name='jack', age=18)
    # c.is_valid(name='jack', age='17')  # ValueError: age must be integer
    cc = c.now()
    print(cc.name, cc.age)  # classmethod可以返回获得和类相关的信息并且可以创建出类的对象
